#!/usr/bin/python3
# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: t -*-

import os
import shutil


class PluginObject:

    def __init__(self, param, api):
        self.mrgetCfgDir = os.path.join(api.getRootDir(), "etc/mrget")

    def stage_working_start_handler(self, requestObj):
        if os.path.exists("/etc/mrget"):
            shutil.copytree("/etc/mrget", self.mrgetCfgDir)
        return {}

    def stage_working_end_handler(self):
        if os.path.exists(self.mrgetCfgDir):
            shutil.rmtree(self.mrgetCfgDir)
